package l1j.server.server.clientpackets;

import l1j.opqlo.Server.L1World.L1World;
import l1j.server.echo.ClientThread;
import l1j.server.server.model.L1Object;
import l1j.server.server.model.Instance.L1AuctionBoardInstance;
import l1j.server.server.model.Instance.L1BoardInstance;

// Referenced classes of package l1j.server.server.clientpackets:
// ClientBasePacket, C_Board

/**
 * 收到由客戶端傳送打開公告欄的封包
 */
public class C_Board extends ClientBasePacket {

	private static final String C_BOARD = "[C] C_Board";

	@Override
	public String getType() {
		return C_BOARD;
	}

	private boolean isBoardInstance(L1Object obj) {
		return obj instanceof L1BoardInstance || obj instanceof L1AuctionBoardInstance;
	}

	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);
		final int objectId = this.readD();
		final L1Object obj = L1World.getInstance().findObject(objectId);
		if (!this.isBoardInstance(obj)) {
			return; // 對象不是佈告欄停止
		}
		obj.onAction(client.getActiveChar());
		} catch (final Exception e) {
			//_log.error(e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}

}
